package com.scopionstudio.adapter;

import java.util.ArrayList;

import com.scopionstudio.lazyload.ImageLoader;
import com.scopionstudio.newpaper.R;
import com.scopionstudio.utils.RessItems;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class NewsAdapter extends ArrayAdapter<RessItems> {
	private LayoutInflater mInflater;
	public ImageLoader imageLoader;

	// private String[] data;
	public NewsAdapter(Context context, int textViewResourceId,
			ArrayList<RessItems> objects) {
		super(context, textViewResourceId, objects);
		// this.data = link;
		mInflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		imageLoader = new ImageLoader(context.getApplicationContext());
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder mHolder;
		RessItems item = this.getItem(position);
		if (null == convertView) {
			convertView = mInflater.inflate(R.layout.news, null);
			mHolder = new ViewHolder();
			mHolder.imgView = (ImageView) convertView
					.findViewById(R.id.imvIconCategory);
			mHolder.newsTittle = (TextView) convertView
					.findViewById(R.id.tvNews);

			convertView.setTag(mHolder);
		} else {
			mHolder = (ViewHolder) convertView.getTag();
		}

		mHolder.imgView.setImageBitmap(item.getbImg());
		mHolder.newsTittle.setText(item.getTitle());
		return convertView;
	}

	private class ViewHolder {
		private ImageView imgView;
		private TextView newsTittle, newsDest, newsDate;
	}

}
